package com.kedacom.ctsp.authz.access;

import com.kedacom.ctsp.authz.entity.Authentication;
import com.kedacom.ctsp.web.entity.UpdaterNameRecordableBeanWithCode;
import com.kedacom.ctsp.web.entity.UpdaterRecordableBeanWithCode;


/**
 * TODO 完成注释
 *
 * @author xuwei
 */
public class UpdaterRecordableBeanHandler extends RecordableBeanHandlerAdaptor<UpdaterRecordableBeanWithCode> {

    @Override
    public void handleSilently(UpdaterRecordableBeanWithCode entity, Authentication auth) {
        entity.setUpdateTimeNow();
        if (auth != null && auth.getUser() != null) {
            entity.setUpdaterCode(auth.getUser().getUsername());
            if (entity instanceof UpdaterNameRecordableBeanWithCode) {
                ((UpdaterNameRecordableBeanWithCode) entity).setUpdaterName(auth.getUser().getName());
            }
        }
    }
}
